var itemHeight = 40;

function openMenu(obj) {
    menu = document.getElementById('menu1');
    indicator = document.getElementById('indicator1');
    height = menu.style.height;

    if (height == "0px" || height == "") {
        childAmount = menu.getElementsByTagName('div').length;
        height = childAmount * itemHeight;
        menu.style.height = height + "px";
        indicator.style.transform = "rotate(-90deg)";
    } else {
        menu.style.height = "0px";
        indicator.style.transform = "rotate(0deg)";
    }
}

function FocusItem(obj)
{
    obj.parentNode.parentNode.className = "";
    var msgBox = obj.parentNode.getElementsByTagName("span")[0];
    msgBox.innerHTML = "";
    msgBox.className = "";
}

function CheckItem(obj)
{
    obj.parentNode.parentNode.className = "";
    var msgBox = obj.parentNode.getElementsByTagName("span")[0];
    switch(obj.name) {
        case "password":
            if(obj.value == "") {
                msgBox.innerHTML = "密码不能为空";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }else if(obj.value.length<6||obj.value.length>20){
                msgBox.innerHTML ="密码长度应该为6-20位！";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }
            break;
        case "rePassword":
            if(obj.value == "") {
                msgBox.innerHTML = "确认密码不能为空";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            } else if(obj.value != document.getElementById("password").value) {
                msgBox.innerHTML = "两次输入的密码不相同";
                msgBox.style.color="red";
                msgBox.className = "error";
                return false;
            }
            break;
    }
    return true;
}